//
//  OtherViewController.m
//  EducationOID
//
//  Created by slz on 2017/5/9.
//  Copyright © 2017年 bnsr. All rights reserved.
//

#import "OtherViewController.h"
#import "HomeTableViewCell.h"
#import <LBXScanView.h>
#import "OIScanViewController.h"
#import "CreatCodeListViewController.h"
#import "SearchOidViewController.h"

@interface OtherViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong) YWTableView *tableView;

@property (nonatomic,strong) NSArray *dataSource;
@property (nonatomic,strong) NSArray *imageSource;
@end

@implementation OtherViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _dataSource = @[@"扫描二维码",@"生成码",@"查询OID"];
    _imageSource = @[@"tool_scan_photo",@"tool_scaning",@"tool_pencle"];//,@"tool_pencle"
    self.showNavigationBar = YES;
    [self setControllerTitle:@"应用中心"];
    [self initTableView];
    // Do any additional setup after loading the view from its nib.
}

- (void)initTableView{
    _tableView = [YWTableView new];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    
    _tableView.showsVerticalScrollIndicator = NO;
    _tableView.showsHorizontalScrollIndicator = NO;
    [self.view addSubview:_tableView];
    @weakify(self);
    [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(weak_self.view);
    }];
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _dataSource.count;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 60;
}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString * reuserString = @"HomeTableViewCell";
    HomeTableViewCell * homeCell = [tableView dequeueReusableCellWithIdentifier:reuserString];
    if (homeCell == nil){
        homeCell = [[HomeTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuserString];
        homeCell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    homeCell.mainLabel.text = _dataSource[indexPath.row];
    homeCell.iconImageView.image = [UIImage imageNamed:_imageSource[indexPath.row]];
    return homeCell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0){
        OIScanViewController * scanViewController = [[OIScanViewController alloc]init];
        scanViewController.style = [self wechatStyle];
        scanViewController.isOpenInterestRect = YES;
        scanViewController.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:scanViewController animated:YES];
    }else if (indexPath.row == 1){
        CreatCodeListViewController * listController = [[CreatCodeListViewController alloc]init];
        [self.navigationController pushViewController:listController animated:YES];
    }else{
        SearchOidViewController * controller = [[SearchOidViewController alloc]init];
        [self.navigationController pushViewController:controller animated:YES];
    }
}

-(LBXScanViewStyle *)wechatStyle{
    //设置扫码区域参数
    LBXScanViewStyle *style = [[LBXScanViewStyle alloc]init];
    
    style.centerUpOffset = 44;
    style.photoframeAngleStyle = LBXScanViewPhotoframeAngleStyle_Inner;
    style.photoframeLineW = 2;
    style.photoframeAngleW = 18;
    style.photoframeAngleH = 18;
    style.isNeedShowRetangle = YES;
    style.anmiationStyle = LBXScanViewAnimationStyle_LineMove;
    style.colorAngle = [UIColor colorWithRed:0./255 green:200./255. blue:20./255. alpha:1.0];
    
    //qq里面的线条图片
    UIImage *imgLine = [UIImage imageNamed:@"qrcode_Scan_weixin_Line"];
    style.animationImage = imgLine;
    return style;
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
